﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ODataRegression.Framework.Core.TestOM;
using ODataRegression.Framework.Core.MetaDataOM;
using ODataRegression.Framework.Core.Shared;
using System.Text.RegularExpressions;
using System.ComponentModel;
using System.Xml;
using ODataTestFrameworkCore.shared;

namespace ODataRegression.Framework.Core.Factories
{
    public class ODataFormatTestFactory : ODataTestFactoryBase
    {
        //int maxTestGenerationCount;
        //int generatedTestCount;
        //Regex verificationToken;
        public override List<ODataTest> CreateTestList()
        {
            //List<ODataTest> testList = new List<ODataTest>();
            EntityBaseURL = entitySet.URL;
            QueryURLBase = EntityBaseURL;
            testName = ODataTestNames.Format;
            testTile = "Verify that $format=txt/MQ/NAS query is working for selected entity";

            
            // If test type not defined in config then return null
            if (this.ISAvtiveTest)
            {
                this.verificationToken = null;
                string TempURL = QueryURLBase + "?$top=100";
                //FinalQueryURL = QueryURLBase + "?$top=100";
                TempURL = URLMappers.ApplyConfigMappingActions(TempURL);
                testName = ODataTestNames.Format;
                
                //FORMAT=TXT
                FinalQueryURL=TempURL  + "&$format=TXT";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=TXT,delimiter=$";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=TXT,delimiter='$'";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=TXT,delimiter=$,header=NO";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=TXT,delimiter=$,header=YES";
                base.CreateTestList();

                //FORMAT=NAS
                FinalQueryURL = TempURL + "&$format=NAS";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=NAS,delimiter=$";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=NAS,delimiter='$'";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=NAS,delimiter=$,header=NO";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=NAS,delimiter=$,header=YES";
                base.CreateTestList();

                //FORMAT=MQ
                FinalQueryURL = TempURL + "&$format=MQ";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=MQ,delimiter=$";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=MQ,delimiter='$'";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=MQ,RID=123456789";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=MQ,delimiter=$,RID=123456789";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=MQ,delimiter=$,RID=123456789,header=NO";
                base.CreateTestList();
                FinalQueryURL = TempURL + "&$format=MQ,delimiter=$,RID=123456789,header=YES";
                base.CreateTestList();


                

                
            }

            return testList;
        }

        public ODataFormatTestFactory(string serviceRoot, string ServiceName, ODataEntitySet entityset )
            : base(serviceRoot, ServiceName, entityset )
        {
            //this.entitySet = entityset;
            //this.ServiceName = ServiceName;
            //this.serviceRoot = serviceRoot;
            //this.testConfig = testConfig;

        }
    }
}
